import Vue from 'vue'
import VueRouter from 'vue-router'

// 解决组件自己跳自己报错问题
const originalPush = VueRouter.prototype.replace
VueRouter.prototype.replace = function replace(location) {
  return originalPush.call(this, location).catch(err => err)
}

Vue.use(VueRouter)

// 引入路由组件
import robotManage from '@/views/robotManage'
import timerTask from '@/views/timerTask'
import getmsg from '@/views/getmsg'
import login from '@/components/login.vue'
import home from '@/views/home.vue'
import robotPerson from '@/views/robotPerson.vue'
import robotPart from '@/views/robotPart.vue'
import robotOpen from '@/views/robotOpen'
import group from '@/views/group'
import department from '@/views/department'

// import subscribe from '@/views/subscribe'
// import askforleave from '@/views/askforleave'
// import haveclass from '@/views/haveclass'




// 配置路由
export default new VueRouter({
  // 路由
  routes: [
    // 登录
    {
      path: '/',
      name: 'login',
      component: login,
    },
    // home
    {
      path: '/home',
      name: 'home',
      component: home,
      children: [
        // 机器人管理
        {
          path: '/home/robotManage',
          name: 'robotManage',
          component: robotManage,
        },
        // 时间管理
        {
          path: '/home/timerTask',
          name: 'timerTask',
          component: timerTask
        },
        // 收集简书地址链接
        {
          path: '/home/getmsg',
          name: 'getmsg',
          component: getmsg
        },
        // 机器人个人问答页面
        {
          path: '/home/robotPerson',
          name: 'robotPerson',
          component: robotPerson
        },
        // 机器人部门问答页面
        {
          path: '/home/robotPart',
          name: 'robotPart',
          component: robotPart
        },
        // 机器人公开问答页面
        {
          path: '/home/robotOpen',
          name: 'robotOpen',
          component: robotOpen
        },
        {
          path: '/home/group',  // 路由参数
          component: group, // 对应的页面组件

        },
        {
          path: '/home/department',
          component: department
        },
        
      ]
    },
  ],
})
